﻿using System;
using System.Collections.Generic;
using System.Xml.Serialization;
using System.Web.Script.Serialization;

using Fuse8.DomainFramework.BusinessService;

using Fuse8.ContentManagementFramework.Domain.Special;
using Fuse8.ContentManagementFramework.SystemFacade;

namespace Fuse8.ContentManagementFramework.Domain
{
    public partial class CmsSiteGroup
    {
        [XmlIgnore]
        [ScriptIgnore]
        public IEnumerable<CmsSite> Sites
        {
            get
            {
                var service = new BusinessServiceFacade<CmsSite, int>();

                return service.Find(p => p.SiteGroupId == Id);
            }
        }

        [XmlIgnore]
        [ScriptIgnore]
        public IEnumerable<CmsConfigurationItem> SiteGroupConfigurationItems
        {
            get
            {
                var container = GetMetaValue<CmsConfigurationItemContainer>(CmsConfiguration.SiteConfigurationElementMetaFieldName);

                return container != null ? container.Items : new List<CmsConfigurationItem>().ToArray();
            }
        }
    }
}
